package com.czl.module_activity.view

import android.webkit.WebView
import android.webkit.WebViewClient

class ActivityDetailWebViewClient() : WebViewClient() {
    override fun onPageFinished(view: WebView?, url: String?) {
        super.onPageFinished(view, url)
        imgReset(view)

    }

    override fun shouldOverrideUrlLoading(view: WebView?, url: String?): Boolean {
        url?.let { view!!.loadUrl(it) }
        return true
    }
    fun imgReset(view: WebView?){
        view!!.loadUrl("javascript:(function(){" +
                "var objs = document.getElementsByTagName('img'); " +
                "for(var i=0;i<objs.length;i++)  " +
                "{"
                + "var img = objs[i];   " +
                "    img.style.maxWidth = '100%'; img.style.height = 'auto';  " +
                "}" +
                "})()")
    }
}